using System;
using System.IO;

namespace PerformanceDude.MSBuildProfiler
{
    public abstract class ContainerStream : Stream
    {
        private readonly Stream _internalStream;

        protected ContainerStream(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentException("Stream can not be null", "stream");
            }
            _internalStream = stream;
        }

        public override bool CanRead
        {
            get { return _internalStream.CanRead; }
        }

        public override bool CanSeek
        {
            get { return _internalStream.CanSeek; }
        }

        public override bool CanWrite
        {
            get { return _internalStream.CanWrite; }
        }

        public override void Flush()
        {
            _internalStream.Flush();
        }

        public override long Length
        {
            get { return _internalStream.Length; }
        }

        public override long Position
        {
            get { return _internalStream.Position; }
            set { _internalStream.Position = value; }
        }

        public override int Read(byte[] buffer, int offset, int count)
        {
            return _internalStream.Read(buffer, offset, count);
        }

        public override long Seek(long offset, SeekOrigin origin)
        {
            return _internalStream.Seek(offset, origin);
        }

        public override void SetLength(long value)
        {
            _internalStream.SetLength(value);
        }

        public override void Write(byte[] buffer, int offset, int count)
        {
            _internalStream.Write(buffer, offset, count);
        }
    }
}